package com.base.action;

import java.util.List;

import com.base.bean.Depotquota;
import com.base.service.CardTypeService;
import com.base.service.DepartmentService;
import com.base.service.DepotquotaService;
import com.base.service.DictService;
import com.common.bean.Cardsubtype;
import com.common.bean.Datadict;
import com.common.bean.Department;
import com.common.util.PagerModel;
import com.common.util.StringToken;
import com.core.ssh2.AbstractActionSupport;
import com.opensymphony.xwork2.Preparable;

public class DepotquotaManagerAction extends AbstractActionSupport implements Preparable{
	private static final long serialVersionUID = 6835303146271809348L;

	private DepotquotaService depotquotaService;
	
	private DepartmentService departmentService;
	
	private CardTypeService cardTypeService;
	
	private DictService dictService;
	
	private Depotquota depotquota;
	
	private long depotid;
	
	private List<Department> departmentlist;
	
	private List<Cardsubtype> cardsubtypelist;
	
	private List<Datadict> datadictlist;
	
	private PagerModel pm;
	
	@SuppressWarnings("unchecked")
	public void prepare() throws Exception {
		cardsubtypelist = cardTypeService.findAllCardsubtype();
		departmentlist = departmentService.findAllleafDepartment();
		datadictlist = dictService.findDictDetail(StringToken.DICT_CARD_DEPOTQUOTA);
	}
	
	@Override
	public String execute() throws Exception {
		return SUCCESS;
	}
	
	public String goAddDepotquota() throws Exception {
		return SUCCESS;
	}
	
	public String addDepotquota() throws Exception {
		depotquotaService.addDepotquota(depotquota);
		return SUCCESS;
	}
	
	public String delDepotquota() throws Exception {
		depotquotaService.removeDepotquota(depotid);
		return SUCCESS;
	}
	
	public String findAllDepotquota() throws Exception {
		pm = depotquotaService.findDepotquotaForPager();
		return SUCCESS;
	}
	
	public String findDepotquota() throws Exception {
		depotquota = depotquotaService.findDepotquota(depotid);
		return SUCCESS;
	}
	
	public String getDepotquotaForUpdate() throws Exception {
		depotquota = depotquotaService.findDepotquota(depotid);
		return SUCCESS;
	}
	
	public String updateDepotquota() throws Exception {
		depotquotaService.updateDepotquota(depotquota);
		return SUCCESS;
	}

	/**
	 * @return the cardsubtypelist
	 */
	public List<Cardsubtype> getCardsubtypelist() {
		return cardsubtypelist;
	}

	/**
	 * @param cardsubtypelist the cardsubtypelist to set
	 */
	public void setCardsubtypelist(List<Cardsubtype> cardsubtypelist) {
		this.cardsubtypelist = cardsubtypelist;
	}

	/**
	 * @return the cardTypeService
	 */
	public CardTypeService getCardTypeService() {
		return cardTypeService;
	}

	/**
	 * @param cardTypeService the cardTypeService to set
	 */
	public void setCardTypeService(CardTypeService cardTypeService) {
		this.cardTypeService = cardTypeService;
	}

	/**
	 * @return the departmentlist
	 */
	public List<Department> getDepartmentlist() {
		return departmentlist;
	}

	/**
	 * @param departmentlist the departmentlist to set
	 */
	public void setDepartmentlist(List<Department> departmentlist) {
		this.departmentlist = departmentlist;
	}

	/**
	 * @return the departmentService
	 */
	public DepartmentService getDepartmentService() {
		return departmentService;
	}

	/**
	 * @param departmentService the departmentService to set
	 */
	public void setDepartmentService(DepartmentService departmentService) {
		this.departmentService = departmentService;
	}

	/**
	 * @return the depotid
	 */
	public long getDepotid() {
		return depotid;
	}

	/**
	 * @param depotid the depotid to set
	 */
	public void setDepotid(long depotid) {
		this.depotid = depotid;
	}

	/**
	 * @return the depotquota
	 */
	public Depotquota getDepotquota() {
		return depotquota;
	}

	/**
	 * @param depotquota the depotquota to set
	 */
	public void setDepotquota(Depotquota depotquota) {
		this.depotquota = depotquota;
	}

	/**
	 * @return the depotquotaService
	 */
	public DepotquotaService getDepotquotaService() {
		return depotquotaService;
	}

	/**
	 * @param depotquotaService the depotquotaService to set
	 */
	public void setDepotquotaService(DepotquotaService depotquotaService) {
		this.depotquotaService = depotquotaService;
	}

	/**
	 * @return the pm
	 */
	public PagerModel getPm() {
		return pm;
	}

	/**
	 * @param pm the pm to set
	 */
	public void setPm(PagerModel pm) {
		this.pm = pm;
	}

	/**
	 * @return the datadictlist
	 */
	public List<Datadict> getDatadictlist() {
		return datadictlist;
	}

	/**
	 * @param datadictlist the datadictlist to set
	 */
	public void setDatadictlist(List<Datadict> datadictlist) {
		this.datadictlist = datadictlist;
	}

	/**
	 * @return the dictService
	 */
	public DictService getDictService() {
		return dictService;
	}

	/**
	 * @param dictService the dictService to set
	 */
	public void setDictService(DictService dictService) {
		this.dictService = dictService;
	}
	
}
